package com.yihr.util;

import java.util.Random;

public class RandomUtil {

    static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray();


    public static String getSalt() {
        return randomHexString(16);
    }

    public static String randomHexString(int len) {
        try {
            StringBuffer result = new StringBuffer();

            Random random = new Random();
            for (int i = 0; i < len; i++) {
                result.append(HEX_DIGITS[random.nextInt(16)]);
            }
            return result.toString();

        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        return null;
    }
}
